home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / forth / pfe-0.000 / pfe-0 / pfe-0.9.13 / src / support.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-17  |  8.0 KB  |  283 lines

  1. /*
  2.  * This file is part of the portable Forth environment written in ANSI C.
  3.  * Copyright (C) 1995  Dirk Uwe Zoller
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Library General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13.  * See the GNU Library General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Library General Public
  16.  * License along with this library; if not, write to the Free
  17.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  * This file is version 0.9.13 of 17-July-95
  20.  * Check for the latest version of this package via anonymous ftp at
  21.  *    roxi.rz.fht-mannheim.de:/pub/languages/forth/pfe-VERSION.tar.gz
  22.  * or    sunsite.unc.edu:/pub/languages/forth/pfe-VERSION.tar.gz
  23.  * or    ftp.cygnus.com:/pub/forth/pfe-VERSION.tar.gz
  24.  *
  25.  * Please direct any comments via internet to
  26.  *    duz@roxi.rz.fht-mannheim.de.
  27.  * Thank You.
  28.  */
  29. /*
  30.  * support.h ---    declare types and prototypes for support.c
  31.  * (duz 09Jul93)
  32.  */
  33.  
  34. #ifndef __SUPPORT_H
  35. #define __SUPPORT_H
  36.  
  37. #ifndef __SYSDEP_H
  38. #include "config.h"
  39. #endif
  40.  
  41. #ifndef __FORTH_H
  42. #include "forth.h"
  43. #endif
  44.  
  45. #ifndef FILE
  46. #include <stdio.h>
  47. #endif
  48.  
  49.  
  50. /* miscellaneous =========================================================== */
  51.  
  52. void millisec (int ms);
  53.  
  54. code (rot);
  55. code (invert);
  56. code (fetch);
  57. code (pocket);
  58. code (update);
  59. code (save_buffers);
  60. code (close_all_files);
  61. code (decimal);
  62. code (key_question);
  63.  
  64. /* strings, memory ========================================================= */
  65.  
  66. Cell aligned (Cell n);
  67. Cell dfaligned (Cell n);
  68. void *getmem (size_t size);
  69. void *xalloc (size_t size);
  70.  
  71. void strpush (const char *s);
  72. char *pocket (void);
  73. int dash_trailing (char *s, int n);
  74. char *strlwr (char *str);
  75. char *strupr (char *str);
  76. void lower (char *p, int n);
  77. void upper (char *p, int n);
  78. char *store_c_string (const char *src, int n, char *dst, int max);
  79. char *store_filename (const char *src, int n, char *dst, int max);
  80. char *expand_filename (const char *nm, const char *path,
  81.                const char *ext, char *fn);
  82. char *search (const char *p1, int u1, const char *p2, int u2);
  83. int match (const char *pattern, const char *string);
  84.  
  85. /* floored divide and number i/o conversion ================================ */
  86.  
  87. udiv_t udiv (uCell num, uCell denom);
  88. fdiv_t fdiv (Cell num, Cell denom);
  89. uCell u_d_div (udCell *ud, uCell denom);
  90. void u_d_mul (udCell *ud, uCell w, uCell c);
  91.  
  92. int dig2num (Byte c, uCell *n, uCell base);
  93. char num2dig (uCell n);
  94. void hold (char c);
  95. const char *to_number (const char *p, uCell *n, udCell *d, uCell base);
  96. int number_question (const char *p, uCell n, dCell *d);
  97.  
  98. char *str_ud_dot_r (udCell ud, char *p, int w, int base);
  99. char *str_d_dot_r (dCell d, char *p, int w, int base);
  100. char *str_dot (Cell n, char *p, int base);
  101.  
  102. code (less_number_sign);
  103. code (number_sign_s);
  104. code (number_sign_greater);
  105.  
  106. code (s_to_d);            /* in core.c */
  107. code (d_dot_r);            /* in double.c */
  108. code (d_dot);            /* in double.c */
  109. code (dot_r);            /* in core.c */
  110. code (dot);            /* in core.c */
  111.  
  112. void d_dot_r (dCell d, int w);
  113. void d_dot (dCell d);
  114. void dot_r (Cell n, int w);
  115. void dot (Cell n);
  116.  
  117. /* console i/o ============================================================= */
  118.  
  119. code (standard_io);
  120.  
  121. void outc (char c);        /* these work on C-strings */
  122. void outs (const char *s);    /* but adjust the OUT variable */
  123. int outf (const char *s, ...);
  124. void type (const char *s, Cell n); /* this works with a Forth-string */
  125. void type_on_line (const char *s, Cell n);
  126.  
  127. code (type);            /* in core.c */
  128. code (space);            /* in core.c */
  129. code (cr);            /* in core.c */
  130. code (backspace);        /* in misc.c */
  131. code (bell);            /* in misc.c */
  132.  
  133. void spaces (int n);
  134. code (spaces);            /* in core.c */
  135.  
  136. void tab (int n);
  137. void dot_line (File *fid, Cell blk, Cell line);
  138. int expect (char *p, Cell n);
  139. int aCcept (char *p, int n);
  140. int question_stop (void);
  141. int question_cr (void);
  142. code (start_question_cr);    /* in misc.c */
  143.  
  144. /* files =================================================================== */
  145.  
  146. long fsize (FILE *f);
  147. long size (const char *fn);
  148. long copy (const char *dst, const char *src, long limit);
  149. int move (const char *src, const char *dst);
  150. int resize (const char *fn, long size);
  151.  
  152. int systemf (const char *s, ...);
  153.  
  154. void file_errorz (const char *fn);
  155. void file_error (const char *fn, int len);
  156. int file_access (const char *fn, int len);
  157. File *create_file (const char *p, int n, int mode);
  158. File *open_file (const char *p, int n, int mode);
  159. int close_file (File *f);
  160. int reposition_file (File *f, long pos);
  161. int read_file (void *p, uCell *n, File *f);
  162. int write_file (void *p, uCell n, File *f);
  163. int resize_file (File *f, long size);
  164. int read_line (char *p, uCell *u, File *f, Cell *ior);
  165.  
  166. /* source input ============================================================ */
  167.  
  168. code (query);
  169. int next_line (void);
  170.  
  171. File *open_block_file (const char *name, int len);
  172. int use_block_file (const char *name, int len);
  173. void read_write (File *f, char *p, uCell n, int readflag);
  174. char *buffer (File *fid, uCell n, int *reload);
  175. char *block (File *fid, uCell n);
  176. void update (File *fid);
  177. void empty_buffers (File *fid);
  178. void save_buffers (File *fid);
  179. void list (File *fid, int n);
  180.  
  181. int refill (void);
  182.  
  183. void *save_input (void *p);
  184. void *restore_input (void *p);
  185. void source (char **p, int *n);
  186. void skip_delimiter (char del);
  187. int parse (char del, char **p, uCell *l);
  188. char *word (char del);
  189.  
  190. /* dictionary and words lists ============================================== */
  191.  
  192. Wordl *word_list (void);
  193. void forget (char *above);
  194.  
  195. int wl_hash (const char *s, int l);
  196. char **topmost (Wordl *w);
  197. char *latest (void);
  198.  
  199. char *search_wordlist (const char *nm, int l, /*const*/ Wordl *w);
  200. char *find (const char *nm, int l);
  201. char *tick (Xt *xt);
  202.  
  203. code (align);            /* in core.c */
  204. code (aligned);
  205.  
  206. char *alloc_string (const char *s, int l);
  207. char *alloc_parsed_string (char del);
  208. char *alloc_word (char del);
  209. void header (pCode cfa, char flags);
  210.  
  211. char **name_to_link (const char *p);
  212. char *link_to_name (char **l);
  213. Xt link_from (char **lnk);
  214. char **to_link (Xt xt);
  215. #define TO_BODY(C)    ((Cell *)((Xt)(C) + 1))
  216. #define BODY_FROM(P)    ((Xt)((Cell *)(P) - 1))
  217. char *to_name (Xt xt);
  218. Xt name_from (const char *p);
  219. Xt runtime (void);
  220. void dot_name (const char *nfa);
  221.  
  222. void wild_words (const Wordl *wl, const char *pattern, const char *category);
  223. int complete_dictionary (char *in, char *out, int display);
  224.  
  225. code (only);
  226. code (also);
  227. code (definitions);
  228. code (default_order);
  229. code (reset_order);
  230.  
  231. uCell pfe_version_code (void);
  232. void preload_dictionary (void);
  233. long save_dictionary (Dict *d1, Dict *d2, const char *fn);
  234. int reload_dictionary (const char *fn, Dict *dict);
  235.  
  236. /* inner and outer interpreter ============================================= */
  237.  
  238. void run_forth (Xt xt);
  239. void call_forth (Xt xt);
  240.  
  241. void normal_execute (Xt xt);
  242. extern void (*execute) (Xt xt);
  243. void debug_off (void);
  244.  
  245. code (interpret);
  246. void evaluate (char *p, int n);
  247. void load (File *fid, uCell blk);
  248. void load_file (char *fn, int cnt, int blk);
  249. void thru (File *fid, int lo, int hi);
  250. void include_file (File *f);
  251. void included (const char *fn, int n);
  252.  
  253. /* ABORT and exception handling ============================================ */
  254.  
  255. extern jmp_buf abort_dest;
  256. extern jmp_buf quit_dest;
  257. void do_abort (void);
  258.  
  259. int cAtch (Xt xt);        /* catch is a keyword in C++ */
  260. void tHrow (int id, ...);    /* accepts -2 addr cnt */
  261. void abortq (const char *fmt, ...); /* accepts printf()-like parameters */
  262.  
  263. code (question_comp);        /* in misc.c */
  264. code (question_exec);
  265. code (question_pairs);
  266. code (store_csp);
  267. code (question_csp);
  268. code (question_loading);
  269. code (question_stack);
  270. void question_pairs (Cell n);
  271. void question_file_open (File *f);
  272.  
  273. void initialize_system (void);
  274.  
  275. /* signal stuff ============================================================ */
  276.  
  277. void install_signal_handlers (void);
  278. void swap_signals (void);
  279. Xt forth_signal (int sig, Xt xt);
  280. void load_signals (Wordl *wid);
  281.  
  282. #endif
  283.